1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gtk.StringFilter;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import glib.c.functions;
30 private import gobject.ObjectG;
31 private import gtk.Expression;
32 private import gtk.Filter;
33 private import gtk.c.functions;
34 public  import gtk.c.types;
35 
36 
37 /**
38  * `GtkStringFilter` determines whether to include items by comparing
39  * strings to a fixed search term.
40  * 
41  * The strings are obtained from the items by evaluating a `GtkExpression`
42  * set with [method@Gtk.StringFilter.set_expression], and they are
43  * compared against a search term set with [method@Gtk.StringFilter.set_search].
44  * 
45  * `GtkStringFilter` has several different modes of comparison - it
46  * can match the whole string, just a prefix, or any substring. Use
47  * [method@Gtk.StringFilter.set_match_mode] choose a mode.
48  * 
49  * It is also possible to make case-insensitive comparisons, with
50  * [method@Gtk.StringFilter.set_ignore_case].
51  */
52 public class StringFilter : Filter
53 {
54 	/** the main Gtk struct */
55 	protected GtkStringFilter* gtkStringFilter;
56 
57 	/** Get the main Gtk struct */
58 	public GtkStringFilter* getStringFilterStruct(bool transferOwnership = false)
59 	{
60 		if (transferOwnership)
61 			ownedRef = false;
62 		return gtkStringFilter;
63 	}
64 
65 	/** the main Gtk struct as a void* */
66 	protected override void* getStruct()
67 	{
68 		return cast(void*)gtkStringFilter;
69 	}
70 
71 	/**
72 	 * Sets our main struct and passes it to the parent class.
73 	 */
74 	public this (GtkStringFilter* gtkStringFilter, bool ownedRef = false)
75 	{
76 		this.gtkStringFilter = gtkStringFilter;
77 		super(cast(GtkFilter*)gtkStringFilter, ownedRef);
78 	}
79 
80 
81 	/** */
82 	public static GType getType()
83 	{
84 		return gtk_string_filter_get_type();
85 	}
86 
87 	/**
88 	 * Creates a new string filter.
89 	 *
90 	 * You will want to set up the filter by providing a string to search for
91 	 * and by providing a property to look up on the item.
92 	 *
93 	 * Params:
94 	 *     expression = The expression to evaluate
95 	 *
96 	 * Returns: a new `GtkStringFilter`
97 	 *
98 	 * Throws: ConstructionException GTK+ fails to create the object.
99 	 */
100 	public this(Expression expression)
101 	{
102 		auto __p = gtk_string_filter_new((expression is null) ? null : expression.getExpressionStruct(true));
103 
104 		if(__p is null)
105 		{
106 			throw new ConstructionException("null returned by new");
107 		}
108 
109 		this(cast(GtkStringFilter*) __p, true);
110 	}
111 
112 	/**
113 	 * Gets the expression that the string filter uses to
114 	 * obtain strings from items.
115 	 *
116 	 * Returns: a `GtkExpression`
117 	 */
118 	public Expression getExpression()
119 	{
120 		auto __p = gtk_string_filter_get_expression(gtkStringFilter);
121 
122 		if(__p is null)
123 		{
124 			return null;
125 		}
126 
127 		return ObjectG.getDObject!(Expression)(cast(GtkExpression*) __p);
128 	}
129 
130 	/**
131 	 * Returns whether the filter ignores case differences.
132 	 *
133 	 * Returns: %TRUE if the filter ignores case
134 	 */
135 	public bool getIgnoreCase()
136 	{
137 		return gtk_string_filter_get_ignore_case(gtkStringFilter) != 0;
138 	}
139 
140 	/**
141 	 * Returns the match mode that the filter is using.
142 	 *
143 	 * Returns: the match mode of the filter
144 	 */
145 	public GtkStringFilterMatchMode getMatchMode()
146 	{
147 		return gtk_string_filter_get_match_mode(gtkStringFilter);
148 	}
149 
150 	/**
151 	 * Gets the search term.
152 	 *
153 	 * Returns: The search term
154 	 */
155 	public string getSearch()
156 	{
157 		return Str.toString(gtk_string_filter_get_search(gtkStringFilter));
158 	}
159 
160 	/**
161 	 * Sets the expression that the string filter uses to
162 	 * obtain strings from items.
163 	 *
164 	 * The expression must have a value type of %G_TYPE_STRING.
165 	 *
166 	 * Params:
167 	 *     expression = a `GtkExpression`
168 	 */
169 	public void setExpression(Expression expression)
170 	{
171 		gtk_string_filter_set_expression(gtkStringFilter, (expression is null) ? null : expression.getExpressionStruct());
172 	}
173 
174 	/**
175 	 * Sets whether the filter ignores case differences.
176 	 *
177 	 * Params:
178 	 *     ignoreCase = %TRUE to ignore case
179 	 */
180 	public void setIgnoreCase(bool ignoreCase)
181 	{
182 		gtk_string_filter_set_ignore_case(gtkStringFilter, ignoreCase);
183 	}
184 
185 	/**
186 	 * Sets the match mode for the filter.
187 	 *
188 	 * Params:
189 	 *     mode = the new match mode
190 	 */
191 	public void setMatchMode(GtkStringFilterMatchMode mode)
192 	{
193 		gtk_string_filter_set_match_mode(gtkStringFilter, mode);
194 	}
195 
196 	/**
197 	 * Sets the string to search for.
198 	 *
199 	 * Params:
200 	 *     search = The string to search for
201 	 *         or %NULL to clear the search
202 	 */
203 	public void setSearch(string search)
204 	{
205 		gtk_string_filter_set_search(gtkStringFilter, Str.toStringz(search));
206 	}
207 }